package thread;

import java.util.Scanner;

public class demo7 {
    private static boolean flag = false;//标志位---标记线程处于终止状态
    public static void main(String[] args) throws InterruptedException {

        Thread t  = new Thread(() ->{
           while(!flag) {
               try {
                   System.out.printf("aaa");
                   Thread.sleep(10000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
        });
        t.start();
        System.out.println("输入0 结束进程t, 输入1继续进程t");
        Scanner in = new Scanner(System.in);
        int tmp = in.nextInt();
        if(tmp == 0 ) {
            flag = true;
        }

    }

}
